static int xcs_data_fd = -1; /* data connection to the xcs server. */
static u32 xcs_session_id = 0;
-int xcs_ctrl_send(xcs_msg_t *msg);
-int xcs_ctrl_read(xcs_msg_t *msg);
-int xcs_data_send(xcs_msg_t *msg);
-int xcs_data_read(xcs_msg_t *msg);
+static int xcs_ctrl_send(xcs_msg_t *msg);
+static int xcs_ctrl_read(xcs_msg_t *msg);
+static int xcs_data_send(xcs_msg_t *msg);
+static int xcs_data_read(xcs_msg_t *msg);
-int xcs_connect(char *ip, short port)
+static int xcs_connect(char *ip, short port)
{
struct sockaddr_in addr;
int ret, flags;
goto data_fd_fail;
}
- /* Haven't put type binding hooks into Xend yet. */
- /* for now, register for everything: */
- /*
- msg.type = XCS_MSG_BIND;
- msg.u.bind.port = PORT_WILDCARD;
- msg.u.bind.type = TYPE_WILDCARD;
- xcs_ctrl_send(&msg);
- xcs_ctrl_read(&msg);
-
- if (msg.result != XCS_RSLT_OK)
- {
- printf("error binding!\n");
- goto data_fd_fail;
- }
- printf("successfully connected to xcs.\n");
- */
return 0;
data_fd_fail:
}
-void xcs_disconnect(void)
+static void xcs_disconnect(void)
{
- printf("xcs_disconnect called!\n");
close(xcs_data_fd);
xcs_data_fd = -1;
close(xcs_ctrl_fd);
xcs_ctrl_fd = -1;
}
-int xcs_ctrl_read(xcs_msg_t *msg)
+static int xcs_ctrl_read(xcs_msg_t *msg)
{
int ret;
ret = read(xcs_ctrl_fd, msg, sizeof(xcs_msg_t));
- if (ret != sizeof(xcs_msg_t)) {
- printf("xu-xcs: ctrl read error (%d)\n", errno);
- /* TODO: set xcs_fd to -1 if the connection has been dropped. */
- } else {
- printf("xu-xcs: read! fd: %d, type: %u\n", xcs_ctrl_fd, msg->type);
- }
return ret;
}
-int xcs_ctrl_send(xcs_msg_t *msg)
+static int xcs_ctrl_send(xcs_msg_t *msg)
{
int ret;
ret = send(xcs_ctrl_fd, msg, sizeof(xcs_msg_t), 0);
- if (ret != sizeof(xcs_msg_t) )
- {
- printf("xu-xcs: ctrl send error(%d)\n", errno);
- /* TODO: set xcs_fd to -1 if the connection has been dropped. */
- } else {
- printf("xu-xcs: sent! fd: %d, type: %u\n", xcs_ctrl_fd, msg->type);
- }
return ret;
}
-int xcs_data_read(xcs_msg_t *msg)
+static int xcs_data_read(xcs_msg_t *msg)
{
int ret;
ret = read(xcs_data_fd, msg, sizeof(xcs_msg_t));
- if (ret != sizeof(xcs_msg_t)) {
- printf("xu-xcs: ctrl read error (%d)\n", errno);
- /* TODO: set xcs_fd to -1 if the connection has been dropped. */
- }
return ret;
}
-int xcs_data_send(xcs_msg_t *msg)
+static int xcs_data_send(xcs_msg_t *msg)
{
int ret;
ret = send(xcs_data_fd, msg, sizeof(xcs_msg_t), 0);
- if (ret != sizeof(xcs_msg_t) )
- {
- printf("xu-xcs: ctrl send error(%d)\n", errno);
- /* TODO: set xcs_fd to -1 if the connection has been dropped. */
- }
return ret;
}
if ( !PyArg_ParseTuple(args, "") )
return NULL;
- printf("xu_notifier_read()\n");
while ((!REQ_RING_FULL) && (!RSP_RING_FULL))
{
break;
return PyErr_SetFromErrno(PyExc_IOError);
}
- printf("notifier got msg type %u\n", ent->msg.type);
+
switch (ent->msg.type)
{
case XCS_REQUEST:
return PyInt_FromLong(ret);
default:
- printf("Throwing away xcs msg type: %u\n", ent->msg.type);
+ /*printf("Throwing away xcs msg type: %u\n", ent->msg.type);*/
free(ent);
}
}
if (!REQ_RING_EMPTY)
{
- printf("nfy: req: %d\n",
- REQ_RING_ENT(req_cons)->msg.u.control.local_port);
return PyInt_FromLong(REQ_RING_ENT(req_cons)->msg.u.control.local_port);
}
if (!RSP_RING_EMPTY)
{
- printf("nfy: rsp: %d\n",
- RSP_RING_ENT(rsp_cons)->msg.u.control.local_port);
return PyInt_FromLong(RSP_RING_ENT(rsp_cons)->msg.u.control.local_port);
}
- printf("nfy: returning None\n");
Py_INCREF(Py_None);
return Py_None;
}
xu_notifier_object *xun;
int i;
-printf("xu_notifier_new()\n");
if ( !PyArg_ParseTuple(args, "") )
return NULL;
static void xu_notifier_dealloc(PyObject *self)
{
+ xcs_disconnect();
PyObject_Del(self);
}
if ((ent == NULL) ||
(ent->msg.u.control.remote_dom != xup->remote_dom))
goto none;
-
-printf("read request (%d:%d)\n", ent->msg.u.control.msg.type,
- ent->msg.u.control.msg.subtype);
cmsg = &ent->msg.u.control.msg;
xum = PyObject_New(xu_message_object, &xu_message_type);
return (PyObject *)xum;
none:
-printf("read request - NO REQUEST!\n");
Py_INCREF(Py_None);
return Py_None;
if ((ent == NULL) ||
(ent->msg.u.control.remote_dom != xup->remote_dom))
goto none;
-
-printf("read response (%d:%d)\n", ent->msg.u.control.msg.type,
- ent->msg.u.control.msg.subtype);
cmsg = &ent->msg.u.control.msg;
xum = PyObject_New(xu_message_object, &xu_message_type);
return (PyObject *)xum;
none:
-printf("read response - NO RESPONSE!\n");
Py_INCREF(Py_None);
return Py_None;
xcs_msg_ent_t *ent;
int found = 0;
unsigned i;
-
-printf("xu_port_request_to_read()\n");
+
if ( !PyArg_ParseTuple(args, "") )
return NULL;
xcs_msg_ent_t *ent;
int found = 0;
unsigned i;
-
-printf("xu_port_response_to_read()\n");
+
if ( !PyArg_ParseTuple(args, "") )
return NULL;
&type) )
return NULL;
- printf("REGISTER : Dom: %3d Port: %3d Type:%3d\n",
- xup->remote_dom, xup->local_port, type);
-
msg.type = XCS_MSG_BIND;
msg.u.bind.port = xup->local_port;
msg.u.bind.type = type;
if (msg.result != XCS_RSLT_OK)
{
- printf(" : REGISTRATION FAILED! (%d)\n", msg.result);
return PyInt_FromLong(0);
}
&type) )
return NULL;
- printf("DEREGISTER: Dom: %3d Port: %3d Type:%3d\n",
- xup->remote_dom, xup->local_port, type);
-
msg.type = XCS_MSG_UNBIND;
msg.u.bind.port = xup->local_port;
msg.u.bind.type = type;
if (msg.result != XCS_RSLT_OK)
{
- printf(" : DEREGISTRATION FAILED! (%d)\n", msg.result);
return PyInt_FromLong(0);
}